package com.dupengcheng.subject.domain.hanler.subject;

import com.dupengcheng.subject.common.enums.IsDeleteEnum;
import com.dupengcheng.subject.common.enums.SubjectTypeEnum;
import com.dupengcheng.subject.domain.entity.SubjectInfoBO;
import com.dupengcheng.subject.domain.entity.SubjectOptionBO;
import com.dupengcheng.subject.infra.basic.entity.SubjectBrief;
import com.dupengcheng.subject.infra.basic.service.SubjectBriefService;
import lombok.Getter;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class BriefHandler implements SubjectTypeHandler {

    @Getter
    private SubjectTypeEnum subjectTypeEnum=SubjectTypeEnum.BRIEF;

    @Resource
    private SubjectBriefService briefService;

    @Override
    public void add(SubjectInfoBO subjectInfoBO) {
        SubjectBrief subjectBrief=new SubjectBrief();

        subjectBrief.setSubjectId(subjectInfoBO.getId());
        subjectBrief.setIsDeleted(IsDeleteEnum.UN_DELETE.getCode());
        subjectBrief.setSubjectAnswer(subjectInfoBO.getSubjectAnswer());
        briefService.insert(subjectBrief);
    }

    @Override
    public SubjectOptionBO query(Long subjectId) {
       SubjectBrief subjectBrief= briefService.queryBySubjectId(subjectId);
        SubjectOptionBO subjectOptionBO=new SubjectOptionBO();
        subjectOptionBO.setSubjectAnswer(subjectBrief.getSubjectAnswer());
        return subjectOptionBO;
    }


}
